<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <script src="layui/layui.js" charset="utf-8"></script>
    <script type="application/javascript" src="js/jquery-1.8.3.min.js"></script>
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
</head>
<body>
<div class="demoTable">
    搜索员工名：
    <div class="layui-inline">
        <input class="layui-input" name="name" id="demoReload" autocomplete="off">
    </div>
    <button class="layui-btn" data-type="reload">搜索</button>
</div>
<table class="layui-hide" id="LAY_table_user" lay-filter="user"></table>


</body>
<script>
    layui.use('table', function () {
        var table = layui.table;

        //方法级渲染
        table.render({
            elem: '#LAY_table_user'
            , url: 'http://localhost:8080/oasys/sign/all.do'
            , cols: [[
                {field: 'id', title: 'ID', sort: true}
                , {field: 'name', title: '姓名'}
                , {field: 'flag', title: '签到'}
                , {field: 'createTime', title: '签到时间'},
            ]]
            , id: 'testReload'
            , page: true
            , height: 310
        });

        var active = {
            reload: function () {

                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        name: $("#demoReload").val()
                    }
                }, 'data');
            }
        };

        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>
</html>
